import {reactive} from "vue";
import http from "../http";
import settings from "../settings.js";
const hospital = reactive({
    hospital_list: [],
    department_id: 1,
    count: 0,
    page: 1,
    hospital_id: 1,
    hospital_info: {},
    doctor_list: [],

    get_hospital_list(){
        // 获取医院信息
        return http.get(`/hospital/hospitalList/${this.department_id}/?page=${this.page}`,).then(response=>{
            console.log('医院信息请求成功..........');
            console.log(response);
            this.hospital_list = response.data.results;
            this.count = response.data.count;
            console.log(this.hospital_list.length)
        }).catch((err) => {
            console.log('医院信息请求失败------');
            console.log(err);
        });
    },
    get_hospital_info(id){
        // 获取医院信息
        return http.get(`/hospital/hospitalInfo/${id}/`,).then(response=>{
            console.log('医院信息请求成功..........');
            console.log(response);
            this.hospital_info = response.data.hospital;
            this.doctor_list = response.data.doctor;
            this.hospital_info.cover = settings.host + this.hospital_info.cover.slice(1)

        }).catch((err) => {
            console.log('医院信息请求失败------');
            console.log(err);
        });
    },
})

export default hospital;